<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>手机号校验</title>
  </head>
  <body>
    <input type="text" id="ip" placeholder="please enter you cellphone" />
    <button id="btn">测试</button>

    <script>
      const reg = /^1[3-9]\d{9}$/;
      btn.onclick = function (e) {
        let isValid = reg.test(ip.value);
        isValid ? alert("合法手机号") : alert("非法手机号");
      };
    </script>
  </body>
</html>
